import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SchoolApi } from '#/api/edu/base/school';
import type { EduSchoolContactApi } from '#/api/edu/base/schoolContact';
import type { SystemDeptExternalApi } from '#/api/system/deptexternal';
import type { DescriptionItemSchema } from '#/components/description';

import { h } from 'vue';

import {
  CommonStatusEnum,
  DICT_TYPE,
  EDU_SCHOOL_CAMPUS_TYPE,
  EDU_SCHOOL_RECRUIT_STATUS,
  EDU_SCHOOL_STATUS,
} from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { formatDate, handleTree } from '@vben/utils';

import { z } from '#/adapter/form';
import { getAdminDepartmentPage } from '#/api/edu/base/adminDepartment';
import { getSchoolPageSimple } from '#/api/edu/base/school';
import { getAreaTreeById } from '#/api/system/area';
import { getDeptListCondition } from '#/api/system/dept';
import { getAdminUserPageSimplePermission } from '#/api/system/user';
import { AMapLocationShow } from '#/components/amap-location-show';
import { DictBadge } from '#/components/dict-badge';
import { DictTag } from '#/components/dict-tag';
import { Image } from '#/components/image';
// 快速添加学校信息
export function baseFastFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'icon',
      label: '学校图标',
      component: 'ImageUpload',
      componentProps: {
        maxNumber: 1,
        params: {
          fileCategoriesCode: 'XXZH',
          objectId: 'XXTB',
          objectType: '学校图标',
        },
      },
    },
    {
      fieldName: 'schoolNum',
      label: '学校代码',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入学校代码' },
    },

    {
      fieldName: 'schoolName',
      label: '学校名称',
      rules: 'required',
      component: 'Input',
      componentProps: { placeholder: '请输入学校名称' },
    },
    {
      fieldName: 'shortName',
      label: '学校简称',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入学校简称' },
    },
    {
      fieldName: 'schoolCampusType',
      label: '学校校区类型',
      component: 'RadioGroup',
      defaultValue: 0,
      rules: 'required',
      componentProps: {
        options: EDU_SCHOOL_CAMPUS_TYPE,
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'schoolType',
      label: '办学类型',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_TYPE, 'string'),
        placeholder: '请选择办学类型',
      },
    },
    {
      fieldName: 'schoolNature',
      label: '办学性质',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_NATURE, 'number'),
        placeholder: '请选择办学性质',
      },
    },
    {
      fieldName: 'periodList',
      label: '学段',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_PERIOD, 'number'),
        mode: 'multiple',
        placeholder: '请选择学段',
      },
    },
    {
      fieldName: 'status',
      label: '学校状态',
      component: 'RadioGroup',
      defaultValue: 1,
      rules: 'required',
      componentProps: {
        options: EDU_SCHOOL_STATUS,
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'masterUnitId',
      label: '主管教育部门',
      component: 'ApiPagingSelect',
      rules: 'required',
      componentProps(values) {
        return {
          allowClear: true,
          api: getAdminDepartmentPage,
          labelField: 'name',
          valueField: 'id',
          autoSelect: 'first',
          placeholder: '请选择主管教育部门',
          onChange: (value, option) => {
            values.masterUnitCode = option.orgCode;
            values.masterUnit = option.name;
            values.areaCode = option.areaCode;
          },
        };
      },
    },
    {
      fieldName: 'masterUnitCode',
      label: '主管部门编码',
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '选择主管教育部门后自动生成',
      },
    },
    {
      fieldName: 'masterUnit',
      component: 'Input',
      label: '主管部门名称',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'areaCode',
      label: '行政区划',
      component: 'ApiTreeSelect',
      rules: 'required',
      componentProps: {
        api: async () => {
          const data = await getDeptListCondition({ type: 'area' });
          return handleTree(data);
        },
        labelField: 'name',
        valueField: 'id',
        childrenField: 'children',
        placeholder: '请选择行政区划',
        treeDefaultExpandAll: true,
        allowClear: true,
      },
    },
    {
      fieldName: 'parentSchoolId',
      label: '上级学校',
      component: 'ApiPagingSelect',
      rules: 'required',
      dependencies: {
        triggerFields: ['schoolCampusType', 'areaCode'],
        show: (values) => values.schoolCampusType !== 0,
        componentProps(values) {
          return {
            allowClear: true,
            key: values.areaCode || 0,
            async api() {
              return await getSchoolPageSimple(
                {
                  status: 1,
                  areaCode: values.areaCode,
                  pageNo: 1,
                  pageSize: 100,
                },
                false,
                false,
              );
            },
            labelField: 'schoolName',
            valueField: 'id',
            placeholder: '请选择上级学校',
          };
        },
      },
    },

    {
      fieldName: 'revokeDate',
      label: '撤销/停办日期',
      component: 'DatePicker',
      rules: 'required',
      componentProps: { format: 'YYYY-MM-DD', valueFormat: 'x' },
      dependencies: {
        triggerFields: ['status'],
        show: (values) => values.status !== 1,
      },
    },
    {
      fieldName: 'mergeSchoolId',
      label: '撤并到学校ID',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入撤并到学校ID' },
      dependencies: {
        triggerFields: ['status'],
        show: (values) => values.status === 2,
      },
    },
    {
      fieldName: 'institutionalCode',
      label: '机构编码',
      component: 'Input',
      componentProps: { placeholder: '请输入机构编码' },
    },
    {
      fieldName: 'licenseNumber',
      label: '统一社会信用代码',
      component: 'Input',
      componentProps: { placeholder: '请输入统一社会信用代码' },
    },
    {
      fieldName: 'sort',
      label: '排序',
      component: 'InputNumber',
      componentProps: { placeholder: '请输入排序' },
    },
    {
      fieldName: 'remarks',
      label: '备注',
      component: 'Textarea',
      componentProps: { placeholder: '请输入备注', rows: 4 },
    },
  ];
}
// 学校基本信息
export function baseFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'icon',
      label: '学校图标',
      component: 'ImageUpload',
      componentProps: {
        maxNumber: 1,
        params: {
          fileCategoriesCode: 'XXZH',
          objectId: 'XXTB',
          objectType: '学校图标',
        },
      },
    },
    {
      fieldName: 'schoolNum',
      label: '学校代码',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入学校代码' },
    },

    {
      fieldName: 'schoolName',
      label: '学校名称',
      rules: 'required',
      component: 'Input',
      componentProps: { placeholder: '请输入学校名称' },
    },
    {
      fieldName: 'shortName',
      label: '学校简称',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入学校简称' },
    },

    {
      fieldName: 'schoolNameEnglish',
      label: '学校英文名',
      component: 'Input',
      componentProps: { placeholder: '请输入学校英文名' },
    },

    {
      fieldName: 'buildDate',
      label: '建校日期',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        placeholder: '请选择建校日期',
      },
    },
    {
      fieldName: 'schoolDay',
      label: '校庆日期',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD',
        valueFormat: 'x',
        placeholder: '请选择校庆日期',
      },
    },
    {
      fieldName: 'email',
      label: '学校邮箱',
      component: 'Input',
      componentProps: { placeholder: '请输入学校邮箱' },
    },
    {
      fieldName: 'postalCode',
      label: '邮编',
      component: 'Input',
      componentProps: { placeholder: '请输入邮编' },
    },
    {
      fieldName: 'sort',
      label: '排序',
      component: 'InputNumber',
      componentProps: { placeholder: '请输入排序' },
    },
    {
      fieldName: 'remarks',
      label: '备注',
      component: 'Textarea',
      componentProps: { placeholder: '请输入备注', rows: 4 },
    },
  ];
}

// 行政隶属关系
export function membershipFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'isCampus',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'schoolCampusType',
      label: '学校校区类型',
      component: 'RadioGroup',
      defaultValue: 0,
      componentProps(values) {
        return {
          options: values.isCampus
            ? EDU_SCHOOL_CAMPUS_TYPE.filter((item) => item.value !== 0)
            : EDU_SCHOOL_CAMPUS_TYPE,
          buttonStyle: 'solid',
          optionType: 'button',
        };
      },
    },

    {
      fieldName: 'masterUnitId',
      label: '主管教育部门',
      component: 'ApiPagingSelect',
      rules: 'required',
      componentProps(values) {
        return {
          disabled: values.isCampus,
          allowClear: true,
          api: getAdminDepartmentPage,
          labelField: 'name',
          valueField: 'id',
          autoSelect: 'first',
          placeholder: '请选择主管教育部门',
          onChange: (value, option) => {
            values.masterUnitCode = option.orgCode;
            values.masterUnit = option.name;
            values.areaCode = option.areaCode;
          },
        };
      },
    },
    {
      fieldName: 'masterUnitCode',
      label: '主管部门编码',
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '选择主管教育部门后自动生成',
      },
    },
    {
      fieldName: 'masterUnit',
      component: 'Input',
      label: '主管部门名称',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'areaCode',
      label: '行政区划',
      component: 'ApiTreeSelect',
      rules: 'required',
      componentProps(values) {
        return {
          disabled: values.isCampus,
          api: async () => {
            const data = await getDeptListCondition({ type: 'area' });
            return handleTree(data);
          },
          labelField: 'name',
          valueField: 'id',
          childrenField: 'children',
          placeholder: '请选择行政区划',
          treeDefaultExpandAll: true,
          allowClear: true,
        };
      },
    },
    {
      fieldName: 'territoryUnitId',
      label: '属地教育部门',
      rules: 'required',
      component: 'ApiPagingSelect',
      componentProps(values) {
        return {
          allowClear: true,
          autoSelect: 'first',
          disabled: values.isCampus,
          api: getAdminDepartmentPage,
          labelField: 'name',
          valueField: 'id',
          placeholder: '请选择属地教育部门',
          onChange: (value, option) => {
            values.territoryUnitCode = option.orgCode;
            values.territoryUnit = option.name;
          },
        };
      },
    },
    {
      fieldName: 'territoryUnitCode',
      label: '属地教育部门编码',
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '选择属地教育部门后自动生成',
      },
    },
    {
      fieldName: 'territoryUnit',
      component: 'Input',
      label: '属地教育部门名称',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'parentSchoolId',
      label: '上级学校',
      component: 'ApiPagingSelect',
      rules: 'required',
      dependencies: {
        triggerFields: ['schoolCampusType', 'areaCode'],
        show: (values) => values.schoolCampusType !== 0,
        componentProps(values) {
          return {
            disabled: values.isCampus,
            allowClear: true,
            key: values.areaCode || 0,
            async api() {
              return await getSchoolPageSimple(
                {
                  status: 1,
                  areaCode: values.areaCode,
                  pageNo: 1,
                  pageSize: 100,
                },
                false,
                false,
              );
            },
            labelField: 'schoolName',
            valueField: 'id',
            placeholder: '请选择上级学校',
          };
        },
      },
    },
    {
      fieldName: 'attachedUnitFlag',
      label: '是否附属学校',
      component: 'RadioGroup',
      defaultValue: false,
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'attachedUnitId',
      label: '附属于',
      component: 'ApiPagingSelect',
      rules: 'required',
      dependencies: {
        triggerFields: ['attachedUnitFlag', 'areaCode'],
        show: (values) => values.attachedUnitFlag,
        componentProps(values) {
          return {
            allowClear: true,
            key: values.areaCode || 0,
            async api() {
              return await getSchoolPageSimple(
                {
                  status: 1,
                  areaCode: values.areaCode,
                  pageNo: 1,
                  pageSize: 100,
                },
                false,
                false,
              );
            },
            labelField: 'schoolName',
            valueField: 'id',
            placeholder: '请选择附属于的学校',
          };
        },
      },
    },
    {
      fieldName: 'attachedUnit',
      component: 'Input',
      label: '附属学校名称',
      dependencies: { triggerFields: [''], show: () => false },
    },
  ];
}
// 地理位置
export function locationFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'areaCode',
      label: '行政区划',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'addressCodeList',
      label: '地址区域',
      component: 'ApiCascader',
      dependencies: {
        triggerFields: ['areaCode'],
        componentProps(values) {
          return {
            key: values.areaCode || 0,
            api: async () => {
              const data = await getAreaTreeById(values.areaCode);
              return data;
            },
            labelField: 'name',
            valueField: 'id',
            childrenField: 'children',
            placeholder: '请选择地址区域',
            treeDefaultExpandAll: true,
            allowClear: true,
            changeOnSelect: true,
            onChange: (value, options) => {
              if (value) {
                values.provinceName = options[0].label;
                values.provinceCode = options[0].id;
                if (options.length > 1) {
                  values.cityName = options[1].label;
                  values.cityCode = options[1].id;
                } else {
                  values.countyName = '';
                  values.streetName = '';
                  values.countyCode = null;
                  values.streetCode = null;
                }
                if (options.length > 2) {
                  values.countyName = options[2].label;
                  values.countyCode = options[2].id;
                } else {
                  values.streetName = '';
                  values.streetCode = null;
                }
                if (options.length > 3) {
                  values.streetName = options[3].label;
                  values.streetCode = options[3].id;
                }
              } else {
                values.provinceName = '';
                values.cityName = '';
                values.countyName = '';
                values.streetName = '';
                values.provinceCode = null;
                values.cityCode = null;
                values.countyCode = null;
                values.streetCode = null;
              }
            },
          };
        },
      },
    },
    {
      fieldName: 'provinceName',
      label: '省份',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'cityName',
      label: '城市',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'countyName',
      label: '区县',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'streetName',
      label: '街道',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'provinceCode',
      label: '省份编码',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'cityCode',
      label: '城市编码',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'countyCode',
      label: '区县编码',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'streetCode',
      label: '街道编',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'addressDetail',
      label: '详细地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入详细地址',
      },
    },
    {
      fieldName: 'schoolLocation',
      label: '地图定位',
      component: 'AMapLocation',
      componentProps(values) {
        return {
          placeholder: '请选择地图定位',
          defaultSearch:
            (values.countyName || '') +
            (values.streetName || '') +
            (values.addressDetail || ''),
          cityValue: values.cityName || values.provinceName || '',
        };
      },
    },
  ];
}
// 办学属性
export function educationFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'schoolType',
      label: '办学类型',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_TYPE, 'string'),
        placeholder: '请选择办学类型',
      },
    },
    {
      fieldName: 'schoolNature',
      label: '办学性质',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_NATURE, 'number'),
        placeholder: '请选择办学性质',
      },
    },
    {
      fieldName: 'periodList',
      label: '学段',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_PERIOD, 'number'),
        mode: 'multiple',
        placeholder: '请选择学段',
      },
    },
    {
      fieldName: 'educationalSystem',
      label: '学制',
      component: 'Input',
      componentProps: { placeholder: '请输入学制' },
    },
    {
      fieldName: 'centerFlag',
      label: '是否为城镇中心学校',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'supportingKindergartenFlag',
      label: '是否配套幼儿园',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'inclusiveFlag',
      label: '是否普惠性幼儿园',
      defaultValue: true,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'keySchoolFlag',
      label: '是否重点学校',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'centreFlag',
      label: '是否中央部署',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'partFlag',
      label: '是否部属学校',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'localLanFlag',
      label: '是否建立校园网',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
  ];
}
// 教学特色
export function featuresFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'bilingualEducationFlag',
      label: '双语教学',
      defaultValue: false,
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'hostLanguage',
      label: '主教学语言',
      component: 'Input',
      componentProps: { placeholder: '请输入主教学语言' },
      dependencies: {
        triggerFields: ['bilingualEducationFlag'],
        show: (values) => values.bilingualEducationFlag,
      },
    },
    {
      fieldName: 'assistLanguage',
      label: '辅教学语言',
      component: 'Input',
      componentProps: { placeholder: '请输入辅教学语言' },
      dependencies: {
        triggerFields: ['bilingualEducationFlag'],
        show: (values) => values.bilingualEducationFlag,
      },
    },
    {
      fieldName: 'ethnicMinorityInstitutions',
      label: '独立设置少数民族学校',
      component: 'RadioGroup',
      defaultValue: false,
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'minorityBilingual',
      label: '少数民族双语教学模式',
      component: 'RadioGroup',
      defaultValue: false,
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'ethnicMinorityLanguage',
      label: '少数民族双语教学语言',
      component: 'Input',
      componentProps: { placeholder: '请输入少数民族双语教学语言' },
    },
  ];
}
// 学校资质信息
export function qualificationFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'institutionalCode',
      label: '机构编码',
      component: 'Input',
      componentProps: { placeholder: '请输入机构编码' },
    },
    {
      fieldName: 'licenseNumber',
      label: '统一社会信用代码',
      component: 'Input',
      componentProps: { placeholder: '请输入统一社会信用代码' },
    },
    {
      fieldName: 'organizationCode',
      label: '组织机构代码',
      component: 'Input',
      componentProps: { placeholder: '请输入组织机构代码' },
    },
    {
      fieldName: 'holdCode',
      label: '举办者码',
      component: 'Input',
      componentProps: { placeholder: '请输入举办者码' },
    },
    {
      fieldName: 'educationalEntity',
      label: '办学主体代码',
      component: 'Input',
      componentProps: { placeholder: '请输入办学主体代码' },
    },
    {
      fieldName: 'institutionLicenseNumber',
      label: '开办许可证号',
      component: 'Input',
      componentProps: { placeholder: '请输入开办许可证号' },
    },
    {
      fieldName: 'institutionUnit',
      label: '审批机关',
      component: 'Input',
      componentProps: { placeholder: '请输入审批机关' },
    },
    {
      fieldName: 'institutionLicenseDate',
      label: '颁证日期',
      component: 'DatePicker',
      componentProps: { format: 'YYYY-MM-DD', valueFormat: 'x' },
    },
    {
      fieldName: 'institutionRegisterNumber',
      label: '登记注册号',
      component: 'Input',
      componentProps: { placeholder: '请输入登记注册号' },
    },
  ];
}
// 状态
export function statusFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'status',
      label: '学校状态',
      component: 'RadioGroup',
      defaultValue: 1,
      rules: 'required',
      componentProps: {
        options: EDU_SCHOOL_STATUS,
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },

    {
      fieldName: 'revokeDate',
      label: '撤销/停办日期',
      component: 'DatePicker',
      rules: 'required',
      componentProps: { format: 'YYYY-MM-DD', valueFormat: 'x' },
      dependencies: {
        triggerFields: ['status'],
        show: (values) => values.status !== 1,
      },
    },
    {
      fieldName: 'mergeSchoolId',
      label: '撤并到学校ID',
      component: 'Input',
      rules: 'required',
      componentProps: { placeholder: '请输入撤并到学校ID' },
      dependencies: {
        triggerFields: ['status'],
        show: (values) => values.status === 2,
      },
    },
    {
      fieldName: 'recruitStatus',
      label: '允许招生状态',
      component: 'RadioGroup',
      defaultValue: 1,
      rules: 'required',
      componentProps: {
        options: EDU_SCHOOL_RECRUIT_STATUS,
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'metadata.talentApplyFlag',
      label: '开通人才申请',
      component: 'RadioGroup',
      defaultValue: false,
      componentProps: {
        options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
  ];
}
/** 学校简介 */
export function introductionFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },

    {
      fieldName: 'coverAnArea',
      label: '占地面积',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入占地面积',
        precision: 2,
        addonAfter: '平方米',
      },
    },
    {
      fieldName: 'floorSpace',
      label: '建筑面积',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入建筑面积',
        precision: 2,
        addonAfter: '平方米',
      },
    },

    {
      fieldName: 'homeUrl',
      label: '学校主页',
      component: 'Input',
      componentProps: { placeholder: '请输入学校主页URL' },
    },
    {
      fieldName: 'headcountNum',
      label: '核定编制人数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入核定编制人数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'facultyStaffNum',
      label: '教职工数量',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入教职工数量',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'leaderNum',
      label: '领导数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入领导数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'teachersNum',
      label: '在编教师数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入在编教师数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'employTeachersNum',
      label: '聘用教师数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入聘用教师数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'temporaryTeachersNum',
      label: '临聘教师数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入临聘教师数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'securityNum',
      label: '安全保卫人数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入安全保卫人数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'retireNum',
      label: '退休人数',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入退休人数',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'studentsNum',
      label: '在校学生数量',
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入在校学生数量',
        precision: 0,
        addonAfter: '人',
      },
    },
    {
      fieldName: 'schoolPhoto',
      label: '学校照片',
      component: 'ImageUpload',
      formItemClass: 'col-span-2',
      componentProps: {
        maxNumber: 10,
        params: {
          fileCategoriesCode: 'XXZH',
          objectId: 'XXZP',
          objectType: '学校照片',
        },
      },
    },
    {
      fieldName: 'briefIntroduction',
      label: '学校简介',
      component: 'RichTextarea',
      componentProps: { placeholder: '请输入学校简介' },
      formItemClass: 'col-span-2',
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'schoolNum',
      label: '学校代码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入学校代码',
      },
    },
    {
      fieldName: 'schoolName',
      label: '学校名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入学校名称',
      },
    },
    {
      fieldName: 'shortName',
      label: '学校简称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入学校简称',
      },
    },
    {
      fieldName: 'status',
      label: '学校状态',
      component: 'RadioGroup',
      defaultValue: 1,
      rules: 'required',
      componentProps: {
        options: EDU_SCHOOL_STATUS,
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'areaCode',
      label: '行政区划',
      component: 'ApiTreeSelect',
      componentProps: {
        api: async () => {
          const data = await getDeptListCondition({ type: 'area' });
          return handleTree(data);
        },
        labelField: 'name',
        valueField: 'id',
        childrenField: 'children',
        placeholder: '请选择行政区划',
        treeDefaultExpandAll: true,
        allowClear: true,
      },
    },
    {
      fieldName: 'schoolType',
      label: '办学类型',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_TYPE, 'string'),
        placeholder: '请选择办学类型',
      },
    },
    {
      fieldName: 'schoolNature',
      label: '办学性质',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_SCHOOL_NATURE, 'number'),
        placeholder: '请选择办学性质',
      },
    },
    {
      fieldName: 'periodList',
      label: '学段',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.EDU_PERIOD, 'number'),
        mode: 'multiple',
        placeholder: '请选择学段',
      },
    },
    {
      fieldName: 'schoolMaster',
      label: '校长姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入校长姓名',
      },
    },
    {
      fieldName: 'masterPhone',
      label: '校长电话',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入校长电话',
      },
    },
    {
      fieldName: 'institutionalCode',
      label: '机构编码',
      component: 'Input',
      componentProps: { placeholder: '请输入机构编码' },
    },
    {
      fieldName: 'licenseNumber',
      label: '社会信用代码',
      component: 'Input',
      componentProps: { placeholder: '请输入统一社会信用代码' },
    },
    {
      fieldName: 'masterIdcard',
      label: '校长身份证',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入校长身份证',
      },
    },
    {
      fieldName: 'schoolCampusType',
      label: '学校校区分类',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: EDU_SCHOOL_CAMPUS_TYPE,
        placeholder: '请选择学校校区分类',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<SchoolApi.School>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    {
      field: 'schoolNum',
      title: '学校代码',
      minWidth: 120,
    },
    {
      field: 'schoolName',
      title: '学校名称',
      minWidth: 120,
    },
    {
      field: 'shortName',
      title: '学校简称',
      minWidth: 120,
    },
    {
      field: 'schoolType',
      title: '办学类型',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.EDU_SCHOOL_TYPE },
      },
    },
    {
      field: 'schoolNature',
      title: '办学性质',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.EDU_SCHOOL_NATURE },
      },
    },
    {
      field: 'periodList',
      title: '学段',
      minWidth: 120,
      slots: { default: 'periodList' },
    },
    {
      field: 'status',
      title: '学校状态',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { options: EDU_SCHOOL_STATUS },
      },
    },
    {
      field: 'schoolMaster',
      title: '校长姓名',
      minWidth: 120,
    },
    {
      field: 'masterPhone',
      title: '校长电话',
      minWidth: 120,
    },
    {
      field: 'schoolAddress',
      title: '学校地址',
      minWidth: 120,
    },
    {
      field: 'institutionalCode',
      title: '机构编码',
      minWidth: 120,
    },
    {
      field: 'licenseNumber',
      title: '统一社会信用代码',
      minWidth: 120,
    },
    {
      field: 'schoolCampusType',
      title: '学校校区分类',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { options: EDU_SCHOOL_CAMPUS_TYPE },
      },
    },
    {
      field: 'parentSchoolName',
      title: '上级名称',
      minWidth: 120,
    },
    {
      field: 'actions',
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
/** 新增/修改的表单 负责人 */
export function useContactFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'schoolId',
      label: '学校',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'contactType',
      label: '负责人类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.SCHOOL_CONTACT_TYPE),
        placeholder: '请选择负责人类型',
      },
    },
    {
      fieldName: 'contactUserId',
      label: '联系人对应的用户',
      component: 'ApiPagingSelect',
      componentProps(values) {
        return {
          api: getAdminUserPageSimplePermission,
          labelField: 'text',
          valueField: 'id',
          placeholder: '请选择联系人对应的用户',
          onChange: (val, option: any) => {
            if (val) {
              values.contactName = option.fullName || option.nickname;
              values.contactPhone = option.mobile;
              values.contactIdcard = option.idcard;
            }
          },
        };
      },
    },
    {
      fieldName: 'contactName',
      label: '联系人姓名',
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: '请输入联系人姓名',
      },
    },
    {
      fieldName: 'contactPhone',
      label: '联系手机',
      rules: 'mobile',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系手机',
      },
    },
    {
      fieldName: 'contactIdcard',
      label: '身份证号',
      rules: 'idcard',
      component: 'Input',
      componentProps: {
        placeholder: '请输入身份证号',
      },
    },
    {
      fieldName: 'contactEmail',
      label: '邮箱',
      component: 'Input',
      rules: 'email',
      componentProps: {
        placeholder: '请输入邮箱',
      },
    },
    {
      fieldName: 'contactTelphone',
      label: '联系固定电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入联系固定电话',
      },
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',
      componentProps: {
        rows: 4,
        placeholder: '请输入备注',
      },
    },
  ];
}
/** 负责人列表的字段 */
export function useContactGridColumns(): VxeTableGridOptions<EduSchoolContactApi.SchoolContact>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '主键',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'schoolId',
      title: '学校id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'schoolName',
      title: '学校名称',
      minWidth: 200,
      visible: false,
    },
    {
      field: 'contactType',
      title: '负责人类型',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.SCHOOL_CONTACT_TYPE },
      },
    },

    {
      field: 'contactName',
      title: '联系人姓名',
      minWidth: 120,
    },
    {
      field: 'contactPhone',
      title: '联系手机',
      minWidth: 120,
    },
    {
      field: 'contactIdcard',
      title: '身份证号',
      minWidth: 150,
    },
    {
      field: 'contactEmail',
      title: '邮箱',
      minWidth: 150,
    },
    {
      field: 'contactTelphone',
      title: '联系固定电话',
      minWidth: 120,
    },
    {
      field: 'remark',
      title: '备注',
      minWidth: 300,
    },
    {
      field: 'contactUserId',
      title: '负责人对应的用户id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
    {
      field: 'actions',
      title: '操作',
      width: 160,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
/** 新增/修改的与外部关系表单 */
export function useExternalFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'orgId',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'type',
      label: '对应关系类型',
      component: 'Select',
      rules: 'required',
      componentProps: {
        options: getDictOptions(DICT_TYPE.SYSTEM_DEPT_EXT_TYPE),
        placeholder: '请选择对应关系类型',
      },
    },
    {
      fieldName: 'externalId',
      label: '对应单位id',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入对应单位id',
      },
    },
    {
      fieldName: 'externalCode',
      label: '对应单位编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入对应单位编码',
      },
    },
    {
      fieldName: 'externalName',
      label: '对应单位名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入对应单位名称',
      },
    },
    {
      fieldName: 'externalShortName',
      label: '对应单位简称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入对应单位简称',
      },
    },
    {
      fieldName: 'status',
      label: '有效状态',
      component: 'Select',
      rules: z.number().default(CommonStatusEnum.ENABLE),
      componentProps: {
        options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
        placeholder: '请选择有效状态',
      },
    },
  ];
}

/** 外部关系列表的字段 */
export function useExternalGridColumns(): VxeTableGridOptions<SystemDeptExternalApi.DeptExternal>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '主键',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'orgId',
      title: '学校id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'type',
      title: '对应关系类型',
      minWidth: 160,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.SYSTEM_DEPT_EXT_TYPE },
      },
    },
    {
      field: 'externalId',
      title: '对应单位id',
      minWidth: 120,
    },
    {
      field: 'externalCode',
      title: '对应单位编码',
      minWidth: 120,
    },
    {
      field: 'externalName',
      title: '对应单位名称',
      minWidth: 300,
    },
    {
      field: 'externalShortName',
      title: '对应单位简称',
      minWidth: 200,
    },
    {
      field: 'status',
      title: '有效状态',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.COMMON_STATUS },
      },
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
    {
      field: 'actions',
      title: '操作',
      width: 160,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

/** 基础详情的字段 */
export function useBaseDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      label: '学校名称',
      field: 'schoolName',
    },
    {
      label: '学校简称',
      field: 'shortName',
    },
    {
      field: 'schoolNameEnglish',
      label: '学校英文名',
    },

    {
      field: 'buildDate',
      label: '建校日期',
      render: (val) => (val ? (formatDate(val, 'YYYY-MM-DD') as string) : ''),
    },
    {
      field: 'schoolDay',
      label: '校庆日期',
      render: (val) => (val ? (formatDate(val, 'YYYY-MM-DD') as string) : ''),
    },
    {
      field: 'email',
      label: '学校邮箱',
    },
    {
      field: 'postalCode',
      label: '邮编',
    },
    {
      field: 'sort',
      label: '排序',
    },
  ];
}
/** 行政隶属关系详情的字段 */
export function useMembershipDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      label: '学校校区类型',
      field: 'schoolCampusType',
      render: (val) => {
        return h(DictTag, {
          options: EDU_SCHOOL_CAMPUS_TYPE,
          value: val,
        });
      },
    },
    {
      label: '行政区划',
      field: 'areaName',
    },
    {
      label: '主管部门编码',
      field: 'masterUnitCode',
    },
    {
      label: '主管部门名称',
      field: 'masterUnit',
    },

    {
      field: 'territoryUnitCode',
      label: '属地教育部门编码',
    },
    {
      field: 'territoryUnit',
      label: '属地教育部门名称',
    },
    {
      field: 'parentSchoolName',
      label: '上级学校',
      show: (values) => values.schoolCampusType !== 0,
    },
    {
      field: 'attachedUnitFlag',
      label: '是否附属学校',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'attachedUnit',
      label: '附属学校名称',
      show: (values) => values.attachedUnitFlag,
    },
  ];
}
export function useContactDetailGridColumns(): VxeTableGridOptions<EduSchoolContactApi.SchoolContact>['columns'] {
  return [
    {
      field: 'id',
      title: '主键',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'schoolId',
      title: '学校id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'schoolName',
      title: '学校名称',
      minWidth: 200,
      visible: false,
    },
    {
      field: 'contactType',
      title: '负责人类型',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.SCHOOL_CONTACT_TYPE },
      },
    },

    {
      field: 'contactName',
      title: '联系人姓名',
      minWidth: 120,
    },
    {
      field: 'contactPhone',
      title: '联系手机',
      minWidth: 120,
    },
    {
      field: 'contactIdcard',
      title: '身份证号',
      minWidth: 150,
    },
    {
      field: 'contactEmail',
      title: '邮箱',
      minWidth: 150,
    },
    {
      field: 'contactTelphone',
      title: '联系固定电话',
      minWidth: 120,
    },
    {
      field: 'remark',
      title: '备注',
      minWidth: 300,
    },
    {
      field: 'contactUserId',
      title: '负责人对应的用户id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
  ];
}
// 地理位置
export function locationDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'schoolAddress',
      label: '学校地址',
    },

    {
      field: 'schoolLocation',
      label: '地图定位',
      render: (val, values) =>
        h(AMapLocationShow, {
          coordinates: val,
          draggable: true,
          height: '200px',
          defaultCity: values.cityName,
        }),
    },
  ];
}
// 办学属性详情
export function useEducationDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'schoolType',
      label: '办学类型',
      render: (val) =>
        h(DictTag, {
          type: DICT_TYPE.EDU_SCHOOL_TYPE,
          value: val,
        }),
    },
    {
      field: 'schoolNature',
      label: '办学性质',
      render: (val) =>
        h(DictTag, {
          type: DICT_TYPE.EDU_SCHOOL_NATURE,
          value: val,
        }),
    },
    {
      field: 'periodList',
      label: '学段',
      render: (val) =>
        h(DictTag, {
          type: DICT_TYPE.EDU_PERIOD,
          value: val,
        }),
    },
    {
      field: 'educationalSystem',
      label: '学制',
    },
    {
      field: 'centerFlag',
      label: '是否为城镇中心学校',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'supportingKindergartenFlag',
      label: '是否配套幼儿园',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'inclusiveFlag',
      label: '是否普惠性幼儿园',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'keySchoolFlag',
      label: '是否重点学校',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'centreFlag',
      label: '是否中央部署',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'partFlag',
      label: '是否部属学校',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'localLanFlag',
      label: '是否建立校园网',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
  ];
}
// 教学特殊详情
export function useFeaturesDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'bilingualEducationFlag',
      label: '双语教学',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'hostLanguage',
      label: '主教学语言',
      show: (values) => values.bilingualEducationFlag,
    },
    {
      field: 'assistLanguage',
      label: '辅教学语言',
      show: (values) => values.bilingualEducationFlag,
    },
    {
      field: 'ethnicMinorityInstitutions',
      label: '独立设置少数民族学校',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'minorityBilingual',
      label: '少数民族双语教学模式',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
    {
      field: 'ethnicMinorityLanguage',
      label: '少数民族双语教学语言',
      show: (values) => values.minorityBilingual,
    },
  ];
}
// 资质认证详情
export function useQualificationDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'institutionalCode',
      label: '机构编码',
    },
    {
      field: 'licenseNumber',
      label: '统一社会信用代码',
    },
    {
      field: 'organizationCode',
      label: '组织机构代码',
    },
    {
      field: 'holdCode',
      label: '举办者码',
    },
    {
      field: 'educationalEntity',
      label: '办学主体代码',
    },
    {
      field: 'institutionLicenseNumber',
      label: '开办许可证号',
    },
    {
      field: 'institutionUnit',
      label: '审批机关',
    },
    {
      field: 'institutionLicenseDate',
      label: '颁证日期',
      render: (val) => (val ? (formatDate(val, 'YYYY-MM-DD') as string) : ''),
    },
    {
      field: 'institutionRegisterNumber',
      label: '登记注册号',
    },
  ];
}
// 运行状态详情
export function useStatusDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'status',
      label: '学校状态',
      render: (val) =>
        h(DictTag, {
          options: EDU_SCHOOL_STATUS,
          value: val,
        }),
    },

    {
      field: 'revokeDate',
      label: '撤销/停办日期',
      render: (val) => (val ? (formatDate(val, 'YYYY-MM-DD') as string) : ''),
      show: (values) => values.status !== 1,
    },
    {
      field: 'mergeSchoolName',
      label: '撤并到学校',
      show: (values) => values.status === 2,
    },
    {
      field: 'recruitStatus',
      label: '允许招生状态',
      render: (val) =>
        h(DictTag, {
          options: EDU_SCHOOL_RECRUIT_STATUS,
          value: val,
        }),
    },
    {
      field: 'metadata.talentApplyFlag',
      label: '开通人才申请',
      render: (val) =>
        h(DictBadge, {
          value: val,
        }),
    },
  ];
}
/** 学校简介 */
export function useIntroductionDetailSchema(): DescriptionItemSchema[] {
  return [
    {
      field: 'coverAnArea',
      label: '占地面积',
      render: (val) => `${val}平方米`,
    },
    {
      field: 'floorSpace',
      label: '建筑面积',
      render: (val) => `${val}平方米`,
    },

    {
      field: 'homeUrl',
      label: '学校主页',
    },
    {
      field: 'headcountNum',
      label: '核定编制人数',
      render: (val) => `${val}人`,
    },
    {
      field: 'facultyStaffNum',
      label: '教职工数量',
      render: (val) => `${val}人`,
    },
    {
      field: 'leaderNum',
      label: '领导数',
      render: (val) => `${val}人`,
    },
    {
      field: 'teachersNum',
      label: '在编教师数',
      render: (val) => `${val}人`,
    },
    {
      field: 'employTeachersNum',
      label: '聘用教师数',
      render: (val) => `${val}人`,
    },
    {
      field: 'temporaryTeachersNum',
      label: '临聘教师数',
      render: (val) => `${val}人`,
    },
    {
      field: 'securityNum',
      label: '安全保卫人数',
      render: (val) => `${val}人`,
    },
    {
      field: 'retireNum',
      label: '退休人数',
    },
    {
      field: 'studentsNum',
      label: '在校学生数量',
      render: (val) => `${val}人`,
    },
    {
      field: 'schoolPhoto',
      label: '学校照片',
      span: 3,
      render: (val) => {
        return val
          ? h(Image, {
              src: val,
              width: 60,
              height: 60,
            })
          : '未上传';
      },
    },
    {
      field: 'briefIntroduction',
      label: '学校简介',
      span: 3,
      render: (val) => h('div', { innerHTML: val }),
    },
  ];
}
/** 外部关系详情的字段 */
export function useExternalDetailGridColumns(): VxeTableGridOptions<SystemDeptExternalApi.DeptExternal>['columns'] {
  return [
    { type: 'seq', width: 40 },
    {
      field: 'id',
      title: '主键',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'orgId',
      title: '学校id',
      minWidth: 120,
      visible: false,
    },
    {
      field: 'type',
      title: '对应关系类型',
      minWidth: 140,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.SYSTEM_DEPT_EXT_TYPE },
      },
    },
    {
      field: 'externalId',
      title: '对应单位id',
      minWidth: 100,
    },
    {
      field: 'externalCode',
      title: '对应单位编码',
      minWidth: 100,
    },
    {
      field: 'externalName',
      title: '对应单位名称',
      minWidth: 200,
    },
    {
      field: 'externalShortName',
      title: '对应单位简称',
      minWidth: 200,
    },
    {
      field: 'status',
      title: '有效状态',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.COMMON_STATUS },
      },
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
  ];
}
